Skip to content

feat(scan): add --dynamic-sbom-inference-ecosystems to choose which ecosystems use Socket facts - #1697

Merged
Jeppe Fredsgaard Blaabjerg (jfblaa) merged 3 commits into
v1.xfrom
jfblaa/dsi-ecosystems-flag
Nov 5, 2026
Merged

Jeppe Fredsgaard Blaabjerg (jfblaa) merged 3 commits into
v1.xfrom
jfblaa/dsi-ecosystems-flag

Conversation

@jfblaa

@jfblaa Jeppe Fredsgaard Blaabjerg (jfblaa) commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

LLM Description written by Claude Code:claude-opus-5-5

Adds --dynamic-sbom-inference-ecosystems to socket scan create, socket scan reach and socket fix, so a repo can use Socket facts for some ecosystems and keep the manifest files of others as they are.

  • Values are purl types, comma-separated or repeated: maven (Gradle, sbt and Maven) and nuget (.NET). Without the flag, both are used, as before.
  • Per ecosystem rather than per build tool, because Coana's facts-only filter works by purl type.
  • Build roots of unselected ecosystems are not discovered at all, so Coana does not treat their ecosystem as facts-only and reads their manifests as usual. With --auto-manifest, auto-generation still runs for them at the scan root.
  • The flag requires --dynamic-sbom-inference, accepts any case, and rejects other ecosystems. Errors for "no build root found" name the selected build tools, and both that error and "no facts produced" suggest choosing other ecosystems.
  • Internally, one dynamicSbomInference option carries the selection (undefined when off), read by one parser shared by the three commands. --reach-ecosystems and fix --ecosystems now also accept any case, through the same ecosystem parser.

Follow-ups to the #1696 review:

  • A .NET build root without a usable .NET SDK now fails like a Maven root without Maven, through the usual failed-root path, instead of a dedicated pre-build check. --json lists it as a failed root. --auto-manifest and socket manifest auto now fail the same way instead of skipping the build.
  • socket fix writes the sidecar whenever it sends the facts-only flag, as reach does, and the facts-only types are typed non-empty.

Tested: unit tests for discovery filtering, the selection passed through scan create, scan reach and fix, the auto-manifest interplay, and flag parsing; manual runs of the built CLI on a Maven + .NET directory (maven selected generates Maven facts and leaves .NET alone; nuget selected on a Maven-only dir fails with the narrowed message).

🤖 Generated with Claude Code

…cosystems use Socket facts

scan create, scan reach and fix take purl types (maven covers Gradle, sbt
and Maven; nuget covers .NET). Build tools of unselected types are not
discovered, so their manifest files are used as they are and Coana does not
treat them as facts-only; with --auto-manifest, auto-generation still runs
for them at cwd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Carried over from my review of #1696, since it merged with these open. Most of them are about code this PR doesn't touch, so they're below rather than inline.

The .NET SDK check runs per root inside the build loop (generate-recursive-manifests.mts). A later .NET root whose global.json pins a missing SDK aborts the run after earlier .NET roots were already built and wrote their facts files. fix resets those files, but scan create and scan reach leave them in the working tree, and the user waited for a build that can't be used. Checking every .NET root before building anything would make the "fails before building anything" test hold in general. Right now it holds only because the test has a single .NET root and dotnet comes first in BUILD_TOOLS.

The no-SDK error skips the JSON output (same lines). socket manifest dynamic-sbom-inference --json used to report a root without an SDK as a skippedNoSdk outcome. Now the InputError escapes handleManifestDynamicSbomInference before its CResult is built, so a script parsing the JSON gets no outcome list.

The wizard checks for an SDK only on one path (setup-recursive-manifest-config.mts). If the user answers no to "Configure other build roots found beneath this one, individually?" (line 853), the wizard reports "Recursive setup complete." without checking any nested .NET root, and the next --dynamic-sbom-inference run fails. On the individual path, returning ok: false looks like it aborts after earlier candidates' socket.json changes were written, leaving the setup half-applied.

Two versions of the no-SDK remedy (wizard and generation). The wizard's version omits the socket.json path and the defaults.manifest.dotnet.disabled option. A shared message builder next to noDotnetSdkReason would keep the two in sync.

useOnlySocketFactsArtifactsFlags accepts an empty list (coana.mts). An empty types produces ['--use-only-socket-facts-artifacts', ''], which Coana rejects with "Unsupported PURL type(s)". This PR can't produce an empty list, since cmdFlagValueToArray drops empty values and factsOnlyTypes comes from the discovered roots. A non-empty tuple type such as readonly [PURL_Type, ...PURL_Type[]] would still rule it out at compile time.

Drop the dedicated .NET SDK probe from --dynamic-sbom-inference and its
setup wizard: a missing SDK now fails the build root the way a missing
Maven does, so the run aborts through the usual failed-root path and
--json lists the root. --auto-manifest keeps warning and skipping.

Also write the sidecar whenever the facts-only flag is sent, for fix as
for reach, type the facts-only types as non-empty, and order the result
fields.
@jfblaa

Copy link
Copy Markdown
Contributor Author

[agent] On the points carried over from #1696 (all in 6748a9d):

  • .NET SDK check per root, JSON output, wizard paths, and the two remedy texts: after discussing it, we removed the dedicated .NET SDK check rather than extending it. A .NET root without a usable SDK now fails like a Maven root without Maven: the facts tool's SDK lookup fails in the same spawn-failure path, the root is failed, and the run aborts as for any failed root. So --json lists the root, the wizard has no SDK branch, and there are no separate remedy texts to keep in sync. Facts files left behind by earlier roots are handled as for any other failed root.
  • Empty facts-only list: FactsOnlyTypes is now readonly [PURL_Type, ...PURL_Type[]], narrowed by isFactsOnlyTypes at the "no build root" check, so useOnlySocketFactsArtifactsFlags can't be called with an empty list.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplification notes, nothing blocking. The most useful are the single dynamicSbomInference field, the shared flag helper and dropping narrowed: together they remove the extra field, the copied code in the three commands and the duplicated messages.

One more that is outside the diff: generate_auto_manifest.mts:229 still skips a .NET root without an SDK through skipWithoutDotnetSdk. The second commit's reasoning ("fail like any other build") would apply to --auto-manifest too, and skipWithoutDotnetSdk in scripts/run.mts could then be deleted. If the skip is intentional there, a short comment saying why would help.

Comment thread src/commands/scan/cmd-scan-create.mts Resolved
Comment thread src/utils/ecosystem.mts Resolved
…ield

- One `dynamicSbomInference` option holds the selected ecosystems, or
  undefined when off, in place of a boolean plus a list.
- `parseDynamicSbomInferenceFlags` reads both flags for scan create,
  scan reach and fix.
- Ecosystem lists are parsed case-insensitively and de-duplicated by
  one parser, which `fix --ecosystems` now uses too.
- The "no build root" message names the selected build tools, and the
  flag's help lists the supported ecosystems from the build-tool table.
- `--auto-manifest` fails a .NET build without a usable SDK, as it does
  a Maven build without Maven, instead of skipping it.
@jfblaa

Copy link
Copy Markdown
Contributor Author

[agent] On skipWithoutDotnetSdk under --auto-manifest (review body): fixed in 18b5d29. --auto-manifest and socket manifest auto now fail a .NET build without a usable SDK, as they do a Maven build without Maven. skipWithoutDotnetSdk is deleted, and the changelog entry covers both.

@jfblaa
Jeppe Fredsgaard Blaabjerg (jfblaa) merged commit a6b221e into v1.x Nov 5, 2026
10 checks passed
@jfblaa
Jeppe Fredsgaard Blaabjerg (jfblaa) deleted the jfblaa/dsi-ecosystems-flag branch November 5, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants